package com.lemon.smartsafetynew.net.services;

import android.content.Context;
import android.util.Log;

import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.Constants;
import com.lemon.smartsafety.app.IApplication;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.http.UrlInfo;
import com.lemon.smartsafety.http.callback.HandlerCallback;
import com.lemon.smartsafety.http.service.BaseHttpServices;
import com.lemon.smartsafetynew.entity.record.AmmonVo;
import com.lemon.smartsafetynew.entity.record.CertificateVo;
import com.lemon.smartsafetynew.entity.record.CompanyBaseVo;
import com.lemon.smartsafetynew.entity.record.CompanyPeopleVo;
import com.lemon.smartsafetynew.entity.record.EmerPlanVo;
import com.lemon.smartsafetynew.entity.record.EmergenVo;
import com.lemon.smartsafetynew.entity.record.EquipVo;
import com.lemon.smartsafetynew.entity.air.AirItmeVo;
import com.lemon.smartsafetynew.entity.highDanger.HighDangerItemVo;
import com.lemon.smartsafetynew.entity.materiel.MaterialVo;
import com.lemon.smartsafetynew.entity.me.MeCompanyVo;
import com.lemon.smartsafetynew.entity.record.DustVo;
import com.lemon.smartsafetynew.entity.record.GridInfoDo;
import com.lemon.smartsafetynew.entity.record.MajorHazardVo;
import com.lemon.smartsafetynew.entity.record.MetalVo;
import com.lemon.smartsafetynew.entity.record.OccupaVo;
import com.lemon.smartsafetynew.entity.record.SafeTrainVo;
import com.lemon.smartsafetynew.entity.record.SpaceVo;
import com.lemon.smartsafetynew.entity.record.SwitchBoxVo;
import com.lemon.smartsafetynew.entity.record.TankVo;
import com.lemon.smartsafetynew.util.constants.KeyConstants;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.List;

/**
 * Created by Andrew on 2017/10/21.
 */

public class RecordServices extends BaseHttpServices {

    public static final String TAG = "RecordServices";

    public RecordServices(Context context) {
        super(context);
    }

    /**
     * 初始化，等同使用构造函数
     *
     * @return
     */
    public static RecordServices init() {
        return new RecordServices(IApplication.context());
    }

    /**
     * 初始化，等同使用构造函数
     *
     * @param context
     * @return
     */
    public static RecordServices init(Context context) {
        return new RecordServices(context);
    }


    /**
     * 搜索企业列表
     */
    public void getCompanyList(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<MeCompanyVo>> callback = new HandlerCallback<List<MeCompanyVo>>(KeyConstants.URL_SEARCH_COMPANY_BY_NAME) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_COMPANY_BY_NAME, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }
    /**
     * 根据模块搜索企业列表
     */
    public void getCompanyListByGridType(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<MeCompanyVo>> callback = new HandlerCallback<List<MeCompanyVo>>(KeyConstants.URL_SEARCH_COMPANY_BY_GRID_TYPE) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_COMPANY_BY_GIRD_TYPE, Constants.SERVER_V2);
       // String serverUrl = UrlInfo.SEARCH_COMPANY_BY_GIRD_TYPE;
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 搜索物料信息
     */
    public void getMaterialInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<MaterialVo>> callback = new HandlerCallback<List<MaterialVo>>(KeyConstants.URL_MATERIAL_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_MATERIAL_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }

    /**
     * 搜索特种设备信息
     */
    public void getEquipInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<EquipVo>> callback = new HandlerCallback<List<EquipVo>>(KeyConstants.URL_EQUIP_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_EQUIP_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }

    /**
     * 搜索储罐信息
     */
    public void getTankInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<TankVo>> callback = new HandlerCallback<List<TankVo>>(KeyConstants.URL_TANK_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_TANK_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }
    /**
     * 搜索粉尘信息
     */
    public void getDustInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<DustVo>> callback = new HandlerCallback<List<DustVo>>(KeyConstants.URL_DUST_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_DUST_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }
    /**
     * 搜索受限空间信息
     */
    public void getSpaceInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<SpaceVo>> callback = new HandlerCallback<List<SpaceVo>>(KeyConstants.URL_SPACE_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_SPACE_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }

    /**
     * 搜索重大危险源信息
     */
    public void getMajorHazardInfo(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<MajorHazardVo>> callback = new HandlerCallback<List<MajorHazardVo>>(KeyConstants.URL_MAJOR_HAZARD_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_MAJOR_HAZARD_BY_COMPANY, Constants.SERVER_V2);
     // String serverUrl = UrlInfo.SEARCH_MAJOR_HAZARD_BY_COMPANY;

        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }

    /**
     * 获取列表
     */
    public void getGridList(LemonRequestParams params) {

        HandlerCallback<List<GridInfoDo>> callback = new HandlerCallback<List<GridInfoDo>>(KeyConstants.URL_GET_GRID_BY_NAME) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_GRID_BY_NAME, Constants.GSAFE);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);

    }

    /**
     * 获得气体列表
     */
    public void getAirInfoList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<AirItmeVo>> callback = new HandlerCallback<List<AirItmeVo>>(KeyConstants.URL_COMPANY_INFO_AIR_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_MONITOR_POSION_AIR_LIST, Constants.SERVER_V2);
                OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    /**
     * 获得高危工艺列表
     */
    public void getHighDangerInfoList(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<HighDangerItemVo>> callback = new HandlerCallback<List<HighDangerItemVo>>(KeyConstants.URL_COMPANY_INFO_HIGH_DANGER_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_MONITOR_HIGH_DANGER_COMPANY_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    /**
     * 获得配电箱列表
     */
    public void getSwitchBoxInfoList(RefreshType type, LemonRequestParams params) {

        HandlerCallback<List<SwitchBoxVo>> callback = new HandlerCallback<List<SwitchBoxVo>>(KeyConstants.URL_COMPANY_INFO_SWITCH_BOX_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_COMPANY_INFO_SWITCH_BOX_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    /**
     * 获得企业基本信息
     */
    public void getCompanyInfo(LemonRequestParams params) {
        HandlerCallback<CompanyBaseVo> callback = new HandlerCallback<CompanyBaseVo>(KeyConstants.URL_GET_RECORD_BASE_INFO) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_RECORD_BASE_INFO, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    //获取职业病列表信息
    public void getOccupationInfo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<OccupaVo>> callback = new HandlerCallback<List<OccupaVo>>(KeyConstants.URL_GET_OCCUPATION_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_OCCUPATION_INFO_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);

    }

    public void getSafeTrainInfo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<SafeTrainVo>> callback = new HandlerCallback<List<SafeTrainVo>>(KeyConstants.URL_GET_SAFE_TRAIN_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SAFE_TRAIN_INFO_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);
    }

    public void getSpecialOperaterInfo(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<CertificateVo>> callback = new HandlerCallback<List<CertificateVo>>(KeyConstants.URL_GET_SPECIAL_OPERATOR_INFO_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_SPECIAL_OPERATOR_INFO_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .params(params)
                .tag(callback.getTag())
                .url(serverUrl)
                .build().execute(callback);
    }

    /**
     * 获取企业人员信息
     */
    public void getCompanyPeopleInfo(LemonRequestParams params) {
        HandlerCallback<List<CompanyPeopleVo>> callback = new HandlerCallback<List<CompanyPeopleVo>>(KeyConstants.URL_GET_RECORD_COMPANY_PEOPLE_INFO) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_RECORD_COMPANY_PEOPLE_INFO, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 重大危险源详情接口
     */
    public void getMajorHazardDetailInfo(LemonRequestParams params) {
        HandlerCallback<List<MajorHazardVo>> callback = new HandlerCallback<List<MajorHazardVo>>(KeyConstants.URL_SEARCH_MAJOR_HAZARD_DETAIL) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.SEARCH_MAJOR_HAZARD_BY_COMPANY, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 获取液氮储罐信息
     */
    public void getAmmoniaList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<AmmonVo>> callback = new HandlerCallback<List<AmmonVo>>(KeyConstants.URL_GET_AMMONIA_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_AMMONIA_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 获取冶金信息
     */
    public void getMetalList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<MetalVo>> callback = new HandlerCallback<List<MetalVo>>(KeyConstants.URL_GET_METAL_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_METAL_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    /**
     * 获取应急物资
     */
    public void getEmergencyList(RefreshType type, LemonRequestParams params) {
        HandlerCallback<List<EmergenVo>> callback = new HandlerCallback<List<EmergenVo>>(KeyConstants.URL_GET_EMERGENCY_LIST) {
        };
        callback.setOther(type);
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_EMERGENCY_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }

    //应急预案列表
    public void getContingencyInfo(LemonRequestParams params) {
        HandlerCallback<List<EmerPlanVo>> callback = new HandlerCallback<List<EmerPlanVo>>(KeyConstants.URL_GET_EMERGENCY_PLAN_LIST) {
        };
        String serverUrl = mSharedPreferencesServer.getRequestUrl(UrlInfo.GET_EMERGENCY_PLAN_LIST, Constants.SERVER_V2);
        OkHttpUtils.post()
                .tag(callback.getTag())
                .url(serverUrl)
                .params(params)
                .build().execute(callback);
    }
}
